<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">通用活动统计（按产品ID）</ui:define>
    <ui:define name="content">
    
    

        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false" draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:commandButton id="flush" value="刷新缓存" icon="fa fa-bolt"
                                         actionListener="#{commActivityRegisterStatBean.onFlushCache()}"
                                         update="@form"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         rendered="#{commActivityRegisterStatBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="导出" ajax="false" icon="ui-icon-arrowthick-1-s">
					        <p:fileDownload value="#{commActivityRegisterStatBean.downloadExcel()}" />
					    </p:commandButton>
					    <p:commandButton value="即时统计数据" ajax="false" icon="ui-icon-arrowthick-1-s">
					        <p:fileDownload value="#{commActivityRegisterStatBean.flushStatData()}" />
					    </p:commandButton>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{commActivityRegisterStatBean.isNormal()}"
                                         actionListener="#{commActivityRegisterStatBean.onReset}"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="startDate" value="开始时间"/>
                                <p:calendar id="startDate" value="#{commActivityRegisterStatBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="selectProduct" value="产品"/>
                                <p:selectCheckboxMenu id="selectProduct" value="#{commActivityRegisterStatBean.$.productId}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{commActivityRegisterStatBean.productList}" var="prod"
                                    	itemValue="#{prod.prdid}" itemLabel="#{prod.name}(#{prod.prdid})"/>                  
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectChannel" value="渠道"/>
                                <p:selectCheckboxMenu id="selectChannel" value="#{commActivityRegisterStatBean.$.channelId}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{commActivityRegisterStatBean.channelList}" var="channel"
                                    	itemValue="#{channel.channel_code}" itemLabel="#{channel.channel_name}(#{channel.channel_code})"/> 
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectPlatform" value="平台"/>
                                <p:selectCheckboxMenu id="selectPlatform" value="#{commActivityRegisterStatBean.$.platform}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{commActivityRegisterStatBean.platformList}" var="pl"
                                    	itemValue="#{pl.platformCode}" itemLabel="#{pl.platformName}"/>
                                </p:selectCheckboxMenu>
                                
                                <p:outputLabel for="endDate" value="结束时间"/>
                                <p:calendar id="endDate" value="#{commActivityRegisterStatBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                            
                                <p:outputLabel for="selectActivityType" value="活动类型"/>
                                <p:selectCheckboxMenu id="selectActivityType" value="#{commActivityRegisterStatBean.$.activityType}"
                                                      updateLabel="true" multiple="true" filter="true"  filterMatchMode="contains">
                                    <f:selectItems value="#{commActivityRegisterStatBean.activityTypeList}" var="type"
                                    	itemValue="#{type.activityType}" itemLabel="#{type.activityTypeName}(#{type.activityType})"/>
                                </p:selectCheckboxMenu>
                                
                                <p:outputLabel for="activityId" value="活动ID"/>
                                <p:inputText id="activityId" value="#{commActivityRegisterStatBean.$.activityId}"/>
                                
                                <p:outputLabel for="selectEnvironment" value="请求环境"/>
                                <p:selectOneMenu id="selectEnvironment" value="#{commActivityRegisterStatBean.$.environment}">
                                    <f:selectItem itemLabel="请选择" itemValue="" noSelectionOption="true"/>
                                   	<f:selectItem itemLabel="推广H5" itemValue="1" noSelectionOption="true"/>
                                   	<f:selectItem itemLabel="客户端" itemValue="2" noSelectionOption="true"/>
                                </p:selectOneMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="statisticRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="statisticRecord"
                                         value="#{commActivityRegisterStatBean.lazyDataModel}"
                                         rows="20"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{commActivityRegisterStatBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="时间">
                                    <h:outputText value="#{statisticRecord.cdate}"/>
                                </p:column>
                                <p:column headerText="产品" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.productName}"/>
                                </p:column>
                                <p:column headerText="渠道" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.channelName}"/>
                                </p:column>
                                <p:column headerText="平台" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.platform}"/>
                                </p:column>
                                <p:column headerText="活动类型" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.activityType}"/>
                                </p:column>
                                <p:column headerText="活动ID" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.activityId}"/>
                                </p:column>
                                <p:column headerText="请求环境" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.environment}"/>
                                </p:column>
                                <p:column headerText="H5-登记人数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.external_register_count}"/>
                                </p:column>
                                <p:column headerText="H5-新注册数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.external_new_register_count}"/>
                                </p:column>
                                <p:column headerText="APP-注册人数（按设备）" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.app_activate_count}"/>
                                </p:column>
                                <p:column headerText="APP-注册人数（按手机号）" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.app_activate_count_phone}"/>
                                </p:column>
                                <p:column headerText="登录数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.login_count}"/>
                                </p:column>
                                <p:column headerText="api提单数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.api_order_count}"/>
                                </p:column>
                                <p:column headerText="api成功提单数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.api_order_success_count}"/>
                                </p:column>
                                <p:column headerText="借条提单数" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.loan_receipt_order_count}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>